package peration;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FriBook implements IOperation{
    @Override
    public void dowork(BookList bookList) {
        System.out.println("请输入你要归还的图书的书名");
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();
        int size = bookList.getUsedSize();
        for(int i=0 ; i<size ;i++){
            Book book = bookList.getBook(i);
            if(book.getName().equals(name)){
                if(book.getFlag()==false){
                    System.out.println(name + "这本书没有被借出");
                    return;
                }
                else{
                    book.setFlag(false);
                    System.out.println("归还成功");
                    return;
                }
            }
        }
    }
}
